package cn.wolfcode.rbac.web.controller;

import cn.wolfcode.rbac.service.ITokenService;
import cn.wolfcode.rbac.util.R;
import cn.wolfcode.rbac.web.vo.LoginVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/tokens")
public class TokenController {
    @Autowired
    private ITokenService tokenService;
    @PostMapping
    public R login(@RequestBody LoginVo vo){
        String token = tokenService.login(vo);
        return R.ok(token);
    }
    @DeleteMapping
    public R logout(@RequestHeader(name = "token") String token){
        tokenService.logout(token);
        return R.ok();
    }
}
